package com.ruoyi.slope.ai.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.slope.dataFile.domain.SlopeDataFile;
import com.ruoyi.slope.dataFile.service.ISlopeDataFileService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.slope.ai.domain.SlopeAiUavDetectionPath;
import com.ruoyi.slope.ai.service.ISlopeAiUavDetectionPathService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 无人机检测路径Controller
 * 
 * @author ruoyi
 * @date 2025-09-05
 */
@RestController
@RequestMapping("/ai/aidrone")
public class SlopeAiUavDetectionPathController extends BaseController
{
    @Autowired
    private ISlopeDataFileService slopeDataFileService;
    @Autowired
    private ISlopeAiUavDetectionPathService slopeAiUavDetectionPathService;

    /**
     * 查询无人机检测路径列表
     */
    @PreAuthorize("@ss.hasPermi('ai:aidrone:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlopeAiUavDetectionPath slopeAiUavDetectionPath)
    {
        startPage();
        List<SlopeAiUavDetectionPath> list = slopeAiUavDetectionPathService.selectSlopeAiUavDetectionPathList(slopeAiUavDetectionPath);
        return getDataTable(list);
    }

    /**
     * 导出无人机检测路径列表
     */
    @PreAuthorize("@ss.hasPermi('ai:aidrone:export')")
    @Log(title = "无人机检测路径", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlopeAiUavDetectionPath slopeAiUavDetectionPath)
    {
        List<SlopeAiUavDetectionPath> list = slopeAiUavDetectionPathService.selectSlopeAiUavDetectionPathList(slopeAiUavDetectionPath);
        ExcelUtil<SlopeAiUavDetectionPath> util = new ExcelUtil<SlopeAiUavDetectionPath>(SlopeAiUavDetectionPath.class);
        String path = util.exportExcel(response, list, "无人机检测路径数据");
        SlopeDataFile slopeDataFile = new SlopeDataFile();
        slopeDataFile.setFileName(path);
        slopeDataFileService.insertSlopeDataFile(slopeDataFile);
    }

    /**
     * 获取无人机检测路径详细信息
     */
    @PreAuthorize("@ss.hasPermi('ai:aidrone:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(slopeAiUavDetectionPathService.selectSlopeAiUavDetectionPathById(id));
    }

    /**
     * 新增无人机检测路径
     */
    @PreAuthorize("@ss.hasPermi('ai:aidrone:add')")
    @Log(title = "无人机检测路径", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlopeAiUavDetectionPath slopeAiUavDetectionPath)
    {
        return toAjax(slopeAiUavDetectionPathService.insertSlopeAiUavDetectionPath(slopeAiUavDetectionPath));
    }

    /**
     * 修改无人机检测路径
     */
    @PreAuthorize("@ss.hasPermi('ai:aidrone:edit')")
    @Log(title = "无人机检测路径", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlopeAiUavDetectionPath slopeAiUavDetectionPath)
    {
        return toAjax(slopeAiUavDetectionPathService.updateSlopeAiUavDetectionPath(slopeAiUavDetectionPath));
    }

    /**
     * 删除无人机检测路径
     */
    @PreAuthorize("@ss.hasPermi('ai:aidrone:remove')")
    @Log(title = "无人机检测路径", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slopeAiUavDetectionPathService.deleteSlopeAiUavDetectionPathByIds(ids));
    }
}
